<?php
$br = (php_sapi_name() == "cli")? "":"<br>";

if(!extension_loaded('Inflector')) {
	dl('Inflector.' . PHP_SHLIB_SUFFIX);
}
$module = 'Inflector';
$functions = get_extension_funcs($module);
echo "Functions available in the test extension:$br\n";
foreach($functions as $func) {
    echo $func."$br\n";
}
echo "$br\n";
$function = 'confirm_' . $module . '_compiled';
if (extension_loaded($module)) {
	$str = $function($module);
} else {
	$str = "Module $module is not compiled into PHP";
}
echo "$str\n";
if (class_exists("Inflector")){
	echo Inflector::underscore("applePie"), PHP_EOL;
}else{
	echo "Class Inflector is not exists!", PHP_EOL;
}
if (class_exists("Inflector") && method_exists("Inflector", "camelize")){
	echo "Testing Inflector::camelize method....", PHP_EOL;
	checkCamelizeMethod();
}else{
	echo "Method Inflector:camelize: is not exists!", PHP_EOL;
}
if (class_exists("Inflector") && method_exists("Inflector", "variable")){
	echo "Testing Inflector::variable method....", PHP_EOL;
	checkVariableMethod();
}else{
	echo "Method Inflector:camelize: is not exists!", PHP_EOL;
}
if(class_exists("Inflector") && method_exists("Inflector", "humanize")){
	echo "Testing Inflector::humanize method....", PHP_EOL;
	checkHumanizeMethod();
}else{
	echo "Method Inflector:humanize: is not exists!", PHP_EOL;
}

echo Inflector::TestConstant, PHP_EOL;

// debug_zval_dump(Inflector::$_plural);


function checkVariableMethod(){
	$inputs = array('apples', 'user_result', 'people_people');
	foreach($inputs as $input){
		echo "Input: {$input} => Output: ", Inflector::variable($input), PHP_EOL;	
	}
}
function checkCamelizeMethod(){
	$inputs = array("Apple_pie", "some_thing", "people_person");
	foreach($inputs as $input){
		echo "Input: {$input} => Output: ", Inflector::camelize($input), PHP_EOL;	
	}
}

function checkHumanizeMethod(){
	$inputs = array("Apple_pie", "some_thing", "people_person", "Apple_PIie", "some____thing", "people__Person");
	foreach($inputs as $input){
		echo "Input: {$input} => Output: ", Inflector::humanize($input), PHP_EOL;
	}
}














